package com.liwalla.domain;

import com.liwalla.domain.Disease;
import java.lang.Integer;
import java.lang.Long;
import java.lang.SuppressWarnings;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PersistenceContext;
import javax.persistence.Version;
import org.springframework.transaction.annotation.Transactional;

privileged aspect Disease_Roo_Entity {
    
    @PersistenceContext
    transient EntityManager Disease.entityManager;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long Disease.id;
    
    @Version
    @Column(name = "version")
    private Integer Disease.version;
    
    public Long Disease.getId() {
        return this.id;
    }
    
    public void Disease.setId(Long id) {
        this.id = id;
    }
    
    public Integer Disease.getVersion() {
        return this.version;
    }
    
    public void Disease.setVersion(Integer version) {
        this.version = version;
    }
    
    @Transactional
    public void Disease.persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }
    
    @Transactional
    public void Disease.remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Disease attached = this.entityManager.find(this.getClass(), this.id);
            this.entityManager.remove(attached);
        }
    }
    
    @Transactional
    public void Disease.flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }
    
    @Transactional
    public Disease Disease.merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Disease merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }
    
    public static final EntityManager Disease.entityManager() {
        EntityManager em = new Disease().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }
    
    public static long Disease.countDiseases() {
        return ((Number) entityManager().createQuery("select count(o) from Disease o").getSingleResult()).longValue();
    }
    
    @SuppressWarnings("unchecked")
    public static List<Disease> Disease.findAllDiseases() {
        return entityManager().createQuery("select o from Disease o").getResultList();
    }
    
    public static Disease Disease.findDisease(Long id) {
        if (id == null) return null;
        return entityManager().find(Disease.class, id);
    }
    
    @SuppressWarnings("unchecked")
    public static List<Disease> Disease.findDiseaseEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("select o from Disease o").setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }
    
}
